<? require_once('../include/connect.inc.php');
	session_start();
	$p=0;
	$choiceT=0;
	$sumChoT=0;
	$sumChoF=0;
	$doT=0;
	$doF=0;
?>


<form name="form1" method="post" action="">
ตรวจข้อสอบหลายตัวเลือก..........!!!!<br>

<?
$query0= query("SELECT * FROM  tb_dotest_detail_q where dotest_id='".$_GET[dotest_id]." '");
		while ($rs0= fetch_array($query0)){
			$type=$rs0['type_id'];
			}
?>
    
<? if($type==2){?>
<?
$sum_multi=0;
$query11= query("SELECT * FROM tb_dotest_detail_q,tb_question where tb_dotest_detail_q.question_id=tb_question.question_id and tb_question.type_id='2' and tb_dotest_detail_q.dotest_id='".$_GET[dotest_id]." ' ");
		while ($rs11= fetch_array($query11)) {
			$question_id11=$rs11['question_id'];
			$p++;
			
$query22= query("SELECT * FROM  tb_choice where question_id=$question_id11");
		while ($rs22= fetch_array($query22)){
			$choice_id22=$rs22['choice_id'];
			$choiceT++;
			}
$query44= query("SELECT * FROM  tb_choice where question_id=$question_id11 and answer=1");
		while ($rs44= fetch_array($query44)){
			$choice_id44=$rs44['choice_id'];
				$sumChoT++;
			}
$query55= query("SELECT * FROM  tb_choice where question_id=$question_id11 and answer=0");
		while ($rs55= fetch_array($query55)){
			$choice_id55=$rs55['choice_id'];
				$sumChoF++;
			}
}
$query33= query("SELECT * FROM tb_dotest_detail,tb_choice where tb_dotest_detail.choice_id=tb_choice.choice_id and tb_choice.answer=1 and tb_dotest_detail.dotest_id='".$_GET[dotest_id]." ' ");
		while ($rs33= fetch_array($query33)){
			$choice_id33=$rs33['choice_id'];
			$doT++;
		}
$query66= query("SELECT * FROM tb_dotest_detail,tb_choice where tb_dotest_detail.choice_id=tb_choice.choice_id and tb_choice.answer=0 and tb_dotest_detail.dotest_id='".$_GET[dotest_id]." ' ");
		while ($rs66= fetch_array($query66)){
			$choice_id66=$rs66['choice_id'];
			$doF++;
		}
?>
<? }?>
<? 
echo "คะแนนรวม";
echo $p;
echo "<br>";
echo "ตัวเลือกทั้งหมด";
echo $choiceT;
echo "<br>";
echo "ถูกรวม";
echo $sumChoT;
echo "<br>";
echo "ผิดรวม";
echo $sumChoF;
echo "<br>";
echo "ทำถูก";
echo $doT;
echo "<br>";
echo "ทำผิด";
echo $doF;
echo "<br>";

echo "ข้อถูกที่ไม่ได้ทำ";
$NoT=$sumChoT-$doT;
echo $NoT;
echo "<br>";
echo "ข้อผิดที่ไม่ได้ทำ";
$NoF=$sumChoF-$doF;
echo $NoF;
echo "<br><br><br>";

echo "ส่วนของการคำนวนหาน้ำหนักแต่ละข้อ";
echo "<br>";

echo "ค่าคะแนนข้อถูกคือ";
$Rf=$p/$sumChoT;
echo $Rf;
echo "<br>";

echo "ค่าคะแนนข้อผิดคือ";
$Wf=$p/$sumChoF;
echo $Wf;
echo "<br>";

echo "ส่วนของการคำนวนหาคะแนน";
$M=$p-(($NoT*$Rf)+($doF*$Wf));
echo $M;
?>
</form>
